package com.jojo.jojomall.search.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
//elasticsearch配置类
@Configuration
public class jojomallElasticConfig {
    public static final RequestOptions COMMON_OPTIONS;
    static {
        RequestOptions.Builder builder =RequestOptions.DEFAULT.toBuilder();
        COMMON_OPTIONS=builder.build();
    }


    @Bean//给容器中注入一个RestHighLevelClient
    public RestHighLevelClient esRestClient(){
        RestHighLevelClient client = new RestHighLevelClient(RestClient.builder(
                new HttpHost("8.130.105.175", 9200, "http")
        ));
        return client;
    }
}
